<html>
<head>
  <style>
    .box {
      position: relative;
      left: 0;
      height: 100px;
      width: 100px;
      margin: 10px;
      background-color: blue;
      -webkit-transition-property: width, left, background-color, height, top;
      -webkit-transition-duration: 0.05s;
    }

    .box1 {
      left: 50px;
    }

    .box2 {
      background-color: red;
      left: 50px;
    }

    .box3 {
      width: 150px;
      background-color: green;
      left: 50px;
      height: 120px;
      -webkit-transition-duration: 0.06s;
    }

    .box4 {
      left: 100px;
      height: 140px;
      -webkit-transition-duration: 0.03s;
    }

    .box5 {
      /* nothing */
    }

  </style>
  <script src="transition-end-event-helpers.js"></script>
  <script type="text/javascript">

    var expectedEndEvents = [
      // [property-name, element-id, elapsed-time, listen]
      ["background-color", "box2", 0.05, false],
      ["background-color", "box3", 0.06, false],
      ["height", "box3", 0.06, false],
      ["height", "box4", 0.03, false],
      ["left", "box1", 0.05, false],
      ["left", "box2", 0.05, false],
      ["left", "box3", 0.06, false],
      ["left", "box4", 0.03, false],
      ["width", "box3", 0.06, false]
    ];

    function transitionElement(index)
    {
      var boxes = document.body.getElementsByClassName('box');
      boxes[index-1].className = "box box" + index;
    }

    function setupTest()
    {
      var boxes = document.body.getElementsByClassName('box');
      for (var i = 0; i < boxes.length; ++i) {
        boxes[i].addEventListener("webkitTransitionEnd", recordTransitionEndEvent, false);
      }

      window.setTimeout(function() { transitionElement(1); }, 40);
      window.setTimeout(function() { transitionElement(2); }, 30);
      window.setTimeout(function() { transitionElement(3); }, 10);
      window.setTimeout(function() { transitionElement(4); }, 20);
      window.setTimeout(function() { transitionElement(5); }, 60);
    }

    runTransitionTest(expectedEndEvents, setupTest);
  </script>
</head>
<body>

<p>Initiating transitions on various properties of all boxes, with different start times on the transitions.</p>

<div id="container">
  <div id="box1" class="box"></div>
  <div id="box2" class="box"></div>
  <div id="box3" class="box"></div>
  <div id="box4" class="box"></div>
  <div id="box5" class="box"></div>
</div>

<div id="result"></div>

</body>
</html>